from sqlalchemy import VARCHAR, BigInteger, Column, DateTime, Integer, String, func

from app.database.base import Base


class User(Base):
    __tablename__ = "users"

    id = Column(Integer, primary_key=True)
    chat_id = Column(BigInteger, unique=True)
    username = Column(String(50))
    was_registered = Column(DateTime, server_default=func.now())

    def __repr__(self):
        return f"<User №{self.id} {self.chat_id}>"

    def __str__(self):
        return self.__repr__()


class Book(Base):
    __tablename__ = "books"

    id = Column(Integer, primary_key=True)
    name = Column(String(255), nullable=False)
    description = Column(VARCHAR(1000), nullable=False)
    quote = Column(VARCHAR(1000))
    level = Column(String(50))
    cover = Column(String(100))
    file_name = Column(String(100))
    was_added = Column(DateTime, server_default=func.now())

    def __repr__(self):
        return f"<Book №{self.id} {self.name}>"

    def __str__(self):
        return self.__repr__()
